package com.techsen.maven.plugins.version;

import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugins.annotations.Mojo;
import org.apache.maven.scm.ScmException;
import org.apache.maven.scm.command.checkin.CheckInScmResult;

@Mojo(name = "commit")
public class CommitMojo extends AbstractScmMojo {

    @Override
    public void execute() throws MojoExecutionException {
        try {
            CheckInScmResult result = this.scmManager.checkIn(this.getScmRepository(), this.getFileSet(),
                    "commit for version: " + this.version);
            this.checkResult(result);
            int size = result.getCheckedInFiles().size();
            this.getLog().info("commit " + size + " files.");
        } catch (ScmException e) {
            throw new MojoExecutionException(e.getMessage(), e);
        }

    }

}
